<%@ page import="java.util.Enumeration"%>
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<html>
<head>
<title>表达式语言</title>
<style type="text/css">
table {
  border-collapse: collapse;
}

td {
  /* 设置最大宽度值 */
  max-width: 280px;
  /* 设置长单词溢出容器时的换行方式 */
  overflow-wrap: break-word;
}
</style>
</head>
<body>
  此页面是由servlet转发从<%=request.getHeader("referer")%>发出的请求后的页面<br>
  <table border="1">
    <tr>
      <th>请求的属性名</th>
      <th>值</th>
      <th>用java表示</th>
      <th>用el表示</th>
    </tr>
    <%
        Enumeration<String> names = request.getAttributeNames();
        while (names.hasMoreElements()) {
            out.print("<tr>");
            String name = names.nextElement();
            out.print("<td>" + name + "</td>");
            out.print("<td>" + request.getAttribute(name) + "</td>");
            out.print("<td>request.getAttribute(\"" + name + "\")</td>");
            out.print("<td>${requestScope['" + name + "']}</td>");
            out.print("</tr>");
        }
    %>
  </table>
  <%
      if (request.getAttribute("object") != null) {
  %>
  \${pageScope.attr.prop}等价于pageContext.getAttribute("attr").getProp()<br>
  \${requestScope.attr.prop}等价于request.getAttribute("attr").getProp()<br>
  \${sessionScope.attr.prop}等价于session.getAttribute("attr").getProp()<br>
  \${applicationScope.attr.prop}等价于application.getAttribute("attr").getProp()<br>
  如果省略作用域scope，则按以下顺序寻找属性名存储的对象（找到存储对象的指定属性名后即终止）
  <table border="1">
    <tr>
      <td>pageScope</td>
      <td>requestScope</td>
      <td>sessionScope</td>
      <td>applicationScope</td>
    </tr>
  </table>
  \${object.field1}=${object.field1}<br>
  \${object.field1*2}=${object.field1*2}<br>
  \${object.field1-3}=${object.field1-3}<br>
  \${object.field2}=${object.field2}<br>
  <%
      }
  %>
  \${param.f1%2}=${param.f1%2}<br>
  \${param.f2}=${param.f2}<br>
  \${param.f1==param.f2}的值等于${param.f1==param.f2}<br>
  \${header['user-agent']}的值等于${header['user-agent']}<br>
  \${header["user-agent"]}的值等于${header["user-agent"]}
</body>
</html>
